<template>
  <base-breadcrumb :title="$route.meta.title">
    <!--安监-安监人员监督日志查看 -->
    <a-form-model
      ref="ruleForm"
      :model="form"
      :label-col="{ span: 6 }"
      :wrapper-col="{ span: 18 }"
    >
      <a-spin :spinning="loading">
        <!-- 表格 -->
        <a-card :bordered="false">
          <title-name title="基本信息"></title-name>
          <custom-form :formList="formList" :form="form" :is-emit="false" :editModel="''">
          </custom-form>
        </a-card>
        <a-card :bordered="false">
          <title-name title="安全教育情况"></title-name>
          <a-table :columns="educationColumns" bordered :pagination="false" :data-source="educationList" >

          </a-table>
        </a-card>
         <a-card :bordered="false">
          <title-name title="安全关键会议"></title-name>
          <a-table :columns="keymeetColumns" bordered :pagination="false" :data-source="keymeetList" ></a-table>
        </a-card>
         <a-card :bordered="false">
          <title-name title="安全检查"></title-name>
          <a-table :columns="checkColumns" bordered :pagination="false" :data-source="checkList" ></a-table>
        </a-card>
        <a-card :bordered="false">
          <title-name title="安全隐患及整改情况"></title-name>
          <a-table :columns="hidrectColumns" bordered :pagination="false" :data-source="hidrectList" ></a-table>
        </a-card>
        <a-card :bordered="false">
          <title-name title="安全技术交底情况"></title-name>
          <a-table :columns="confessColumns" bordered :pagination="false" :data-source="confessList" ></a-table>
        </a-card>
        <a-card :bordered="false">
          <title-name title="安全验收情况"></title-name>
          <a-table :columns="acceptColumns" bordered :pagination="false" :data-source="acceptList" ></a-table>
        </a-card>
        <a-card :bordered="false">
          <title-name title="重大危险源旁站监督"></title-name>
          <a-table :columns="sidestandColumns" bordered :pagination="false" :data-source="sidestandList" ></a-table>
        </a-card>
        <a-card :bordered="false">
          <title-name title="高风险作业许可审批情况"></title-name>
          <a-table :columns="dangerworkColumns" bordered :pagination="false" :data-source="dangerworkList" ></a-table>
        </a-card>
        <a-card :bordered="false">
          <title-name title="领导带班情况"></title-name>
          <a-table :columns="managerColumns" bordered :pagination="false" :data-source="managerList" ></a-table>
        </a-card>
        <a-card :bordered="false">
          <title-name title="其他"></title-name>
          <div class="remark" v-html="form.remark"></div>
        </a-card>
        <!-- 页脚操作栏 -->
        <div class="btn_box page-btn-right-top">
          <a-button @click="handleActiveClose">关闭</a-button>
        </div>
      </a-spin>
    </a-form-model>
     
  </base-breadcrumb>
</template>

<script>
import { getSafeSupervisionLog } from '@/api/safetySupervision/monitorLog'
import BaseEditPage from '@/views/baseEditPage' // 编辑详情页基础配置
import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司
import SelectProject from '@/components/Select/SelectProject' // 分公司
export default {
  name: 'a' + Date.now(),
  extends: new BaseEditPage(),
  components: {
    SelectSubCompany,
    SelectProject
  },
  data() {
     this.educationColumns = [
   {
          title: '序号',
          width: '4%',
          align: 'center',
          dataIndex: 'index',
          customRender() {
            return arguments[2] + 1
            }},
      { title: '教育类型', align: 'center', dataIndex: 'type',width:'12%'},
      { title: '教育名称', dataIndex: 'name', align: 'center',width:'12%'},
      { title: '教育负责人', dataIndex: 'director', align: 'center',width:'12%'},
      { title: '受教育对象', dataIndex: 'edobject', align: 'center',width:'12%'},
      { title: '人数', dataIndex: 'number', align: 'center',width:'12%',},
      { title: '教育内容', dataIndex: 'content', align: 'center',width:'36%',},
    ]
     this.keymeetColumns = [
   {
          title: '序号',
          width: '4%',
          align: 'center',
          dataIndex: 'index',
          customRender() {
            return arguments[2] + 1
            }},
      { title: '会议名称', align: 'center', dataIndex: 'name',width:'12%'},
      { title: '主持人', dataIndex: 'presenter', align: 'center',width:'12%'},
      { title: '主要参会者', dataIndex: 'joinusers', align: 'center',width:'12%'},
      { title: '人数', dataIndex: 'number', align: 'center',width:'12%'},
      { title: '开会时间', dataIndex: 'statileDate', align: 'center',width:'12%',},
      { title: '会议说明', dataIndex: 'content', align: 'center',width:'36%'},
    ]
     this.checkColumns = [
      {
          title: '序号',
          width: '4%',
          align: 'center',
          dataIndex: 'index',
          customRender() {
            return arguments[2] + 1
            }},
      { title: '检查类型', align: 'center', dataIndex: 'type',width:'12%'},
      { title: '检查人', dataIndex: 'checkUser', align: 'center',width:'12%'},
      { title: '检查区域', dataIndex: 'checkArea', align: 'center',width:'12%'},
      { title: '检查结果', dataIndex: 'checkResult', align: 'center',width:'12%'},
      { title: '检查时间', dataIndex: 'statileDate', align: 'center',width:'12%'},
      { title: '检查详情', dataIndex: 'content', align: 'center',width:'36%',},
    ]
      this.hidrectColumns = [
       {
          title: '序号',
          width: '4%',
          align: 'center',
          dataIndex: 'index',
          customRender() {
            return arguments[2] + 1
            }},
      { title: '隐患类型', align: 'center', dataIndex: 'type',width:'12%'},
      { title: '隐患位置', dataIndex: 'area', align: 'center',width:'12%'},
      { title: '隐患整改责任人', dataIndex: 'director', align: 'center',width:'12%'},
      { title: '验收人', dataIndex: 'inspectedUser', align: 'center',width:'12%'},
      { title: '隐患整改结果', dataIndex: 'content', align: 'center',width:'48%',},
    ]
      this.confessColumns = [
       {
          title: '序号',
          width: '4%',
          align: 'center',
          dataIndex: 'index',
          customRender() {
            return arguments[2] + 1
            }},
      // { title: '施工工序', align: 'center', dataIndex: 'type',width:'12%'},
      { title: '交底名称', align: 'center', dataIndex: 'name',width:'16%'},
      { title: '交底人', dataIndex: 'confessUser', align: 'center',width:'14%'},
      { title: '监督人', dataIndex: 'supervisorUser', align: 'center',width:'14%'},
      { title: '被交底单位', dataIndex: 'coverUser', align: 'center',width:'14%'},
      { title: '工种', dataIndex: 'workType', align: 'center',width:'14%'},
      { title: '交底要点', dataIndex: 'content', align: 'center',width:'36%',},
    ]
      this.acceptColumns = [
      {
          title: '序号',
          width: '4%',
          align: 'center',
          dataIndex: 'index',
          customRender() {
            return arguments[2] + 1
            }},
      { title: '验收部位', align: 'center', dataIndex: 'accpart',width:'15%'},
      { title: '验收负责人', dataIndex: 'director', align: 'center',width:'15%'},
      { title: '验收类别', dataIndex: 'type', align: 'center',width:'15%'},
      { title: '分包单位', dataIndex: 'subContractorName', align: 'center',width:'15%'},
      { title: '验收结果', dataIndex: 'content', align: 'center',width:'36%',},
    ]
      this.sidestandColumns = [
    {
          title: '序号',
          width: '4%',
          align: 'center',
          dataIndex: 'index',
          customRender() {
            return arguments[2] + 1
            }},
      { title: '旁站内容', align: 'center', dataIndex: 'name',width:'10%'},
      { title: '作业单位', dataIndex: 'workDept', align: 'center',width:'10%'},
      { title: '作业人员', dataIndex: 'workUser', align: 'center',width:'10%'},
      { title: '旁站时间', dataIndex: 'statileDate', align: 'center',width:'10%'},
      { title: '旁站人员', dataIndex: 'sideStandWorker', align: 'center',width:'10%'},
      { title: '旁站部位', dataIndex: 'workPart', align: 'center',width:'10%'},
      { title: '监督过程要点', dataIndex: 'content', align: 'center',width:'36%',},
    ]
    this.dangerworkColumns = [
  {
          title: '序号',
          width: '4%',
          align: 'center',
          dataIndex: 'index',
          customRender() {
            return arguments[2] + 1
            }},
      { title: '危险作业类型', align: 'center', dataIndex: 'type',width:'16%'},
      { title: '申请人', dataIndex: 'applyUser', align: 'center',width:'16%'},
      { title: '分包单位', dataIndex: 'subContractorName', align: 'center',width:'16%'},
      { title: '班组', dataIndex: 'subTeam', align: 'center',width:'16%'},
      { title: '危险作业位置', dataIndex: 'area', align: 'center',width:'16%'},
      { title: '申请时间', dataIndex: 'applyDate', align: 'center',width:'16%'},
    ]
    this.managerColumns = [
      {
          title: '序号',
          width: '4%',
          align: 'center',
          dataIndex: 'index',
          customRender() {
            return arguments[2] + 1
            }},
      { title: '带班领导', align: 'center', dataIndex: 'manager',width:'16%'},
      { title: '现场安全生产状况和管理情况', dataIndex: 'content', align: 'center',width:'40%'},
      { title: '下一步安全生产工作要求', dataIndex: 'jobrequire', align: 'center',width:'40%'},
    ]
    return {
      loading: false, // 加载控件
      visible: false, //人员选择控件
      editModel: 0, // 操作状态:0 查看;1 编辑;2 新增
      form: { branchComName:'', viewName: ''}, // 表单
      id: '',
      init: false, // 初始化控件
      educationList:[], //安全教育情况
      keymeetList:[], //	安全关键会议
      checkList:[], //安全检查
      hidrectList:[], //安全隐患及整改情况
      confessList:[],  //安全技术交底情况
      acceptList:[],  //	安全验收情况
      sidestandList:[], //	重大危险源旁站监督
      dangerworkList:[], //	高风险作业许可审批情况
      managerList:[],  //领导带班情况
      confessColumnsOne:[],
      confessColumnsTwo:[],
    }
  },
  async mounted() {
    this.$route.meta.title = '安全监督日志 查看';
    await this.getDetailData();
    if(this.queryType*1===1){
    }else{
      this.confessColumns[4].title="被交底人"
    }
  },
  computed: {
    formList() {
      return [
        {type: 'BaseInput',keyName: 'viewName',label: '所属单位',disabled: true, span: 16},
        // {type: 'BaseInput',keyName: 'projectName',label: '所属项目',disabled: true,},
        {keyName: 'statileDate',type: 'BaseInput',disabled: true,label: '统计日期',},
        {keyName: 'creatorName',type: 'BaseInput',disabled: true,label: '填报人',hidden:this.queryType*1===2},
        {keyName: 'creatorDept',type: 'BaseInput',disabled: true,label: '填报人职位',hidden:this.queryType*1===2},
      ]
    },
  },
  methods: {
    getDetailData() {
      // 不为添加时请求详情
     this.loading = true
     let reqObj ={};
     if(this.queryType*1===1){
       reqObj = {
          id: this.projectId,queryTypeNum:this.queryType
       }
     }else{
        reqObj = {
          projectId: this.projectId,queryTypeNum:this.queryType,statileDate:this.statileDate
       }
     }
        getSafeSupervisionLog(reqObj)
          .then((res) => {
            this.loading = false
            this.form = { ...this.form, ...res.data }
            this.form.viewName = this.form.branchCompanyName + '/' + this.form.projectName
           this.form.remark = this.clearComma(this.form.remark)
            const {educationList=[],keymeetList=[],checkList=[],hidrectList=[],confessList=[],acceptList=[],sidestandList=[],dangerworkList=[],managerList=[]} = res.data || {};
            this.educationList =educationList;
            this.keymeetList =keymeetList;
            this.checkList =checkList;
            this.hidrectList =hidrectList;
            this.confessList =confessList;
            this.acceptList =acceptList;
            this.sidestandList =sidestandList;
            this.dangerworkList =dangerworkList;
            this.managerList =managerList;
            this.$nextTick(() => {
              this.init = true
            })
          })
          .catch(() => {
            this.loading = false
          })
    },
    clearComma(str) {
       if(str){
         str = str.replace(/,/g, "");//取消字符串中出现的所有逗号
       }
       return str || '';
      }
  }
}
</script>
<style lang="less" scoped>
.remark{
  background-color: #f5f5f5;
  min-height: 100px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  padding: 10px;
  line-height: 16px;
}
</style>
